<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

Route::get('/', function () {
    return redirect('/blog');
});

Route::get('/blog', 'BlogController@index')->name('blog.name');
Route::get('/blog/{slug}', 'BlogController@showPost')->name('blog.detail');

// 后台路由
Route::get('/admin', function () {
    return redirect('/admin/post');
});

Route::middleware('auth')->namespace('Admin')->group(function () {
    // 文章资源路由,移除文章显示路由
    Route::resource('admin/post', 'PostController', ['except' => 'show']);
    // 排除未用到的路由
    Route::resource('admin/tag', 'TagController', ['except' => 'show']);
    // 文件上传路由
    Route::get('admin/upload', 'UploadController@index');
    Route::post('admin/upload/file', 'UploadController@uploadFile');
    Route::delete('admin/upload/file', 'UploadController@deleteFile');
    Route::post('admin/upload/folder', 'UploadController@createFolder');
    Route::delete('admin/upload/folder', 'UploadController@deleteFolder');
});

// 后台注册
Route::get('/login', 'Auth\LoginController@showLoginForm')->name('login');
// 约定post带get谓词参数ugrant意为向oauth服务密码授权令牌(ugrant之passport分支)
Route::post('/login', 'Auth\LoginController@login');
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');

// 联系人
Route::get('contact', 'ContactController@showForm');
Route::post('contact', 'ContactController@sendContactInfo');
// rss
Route::get('rss', 'BlogController@rss');
// siteMap
Route::get('sitemap.xml', 'BlogController@siteMap');
Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');


// #######################
// 认证与授权系列
// #######################

// 第三方应用授权码获取令牌
Route::get('/auth', 'Auth\LoginController@oauth');
Route::get('/auth/callback', 'Auth\LoginController@callback');

// 客户端令牌
Route::get('/auth/client','Auth\LoginController@client');

// 隐式授权令牌
Route::get('/auth/implicit', 'Auth\LoginController@implicit');
Route::get('/auth/implicit/callback', 'Auth\LoginController@implicitCallback');